package com.zhengx.fragmentutil;

import android.util.Log;

import androidx.fragment.app.Fragment;

/**
 * name：com.zhengx.fragmentutil
 * class: fragment基类样板
 * author: zhengx
 * create_time: 19-7-25
 */
public class BaseQuickFragment extends Fragment implements IFragmentBackHandler{

    private boolean isDebug = true;

    private boolean isFirstInit = true;

    protected void doLazyBusiness(){}

    @Override
    public void onResume() {
        super.onResume();
        if (isFirstInit) {
            isFirstInit = false;
            debug("fragment first visible");
            doLazyBusiness();
        }
    }

    protected void debug(String msg) {
        if (isDebug) {
            Log.d(this.getClass().getSimpleName(), "" + msg);
        }
    }

    public boolean onInterceptBackPressed() {
        return false;
    }

    @Override
    public boolean onBackPressed() {
        return onInterceptBackPressed() || FragmentUtil.handleFragmentsBackPressed(this);
    }
}
